package com.aidex.quartz.task;

import com.aidex.biz.domain.*;
import com.aidex.biz.domain.bo.BusinessSetBo;
import com.aidex.biz.domain.enums.CustomerEnum;
import com.aidex.biz.domain.enums.MessageTypeEnum;
import com.aidex.biz.rong360.Rong360Service;
import com.aidex.biz.service.*;
import com.aidex.biz.utils.RAESUtils;
import com.aidex.common.core.domain.entity.SysUser;
import com.aidex.common.core.redis.RedisCache;
import com.aidex.common.utils.StringUtils;
import com.aidex.common.utils.http.HttpUtils;
import com.aidex.common.utils.sms.ChuangLanSmsClient;
import com.aidex.framework.cache.ConfigUtils;
import com.aidex.framework.websocket.WebSocketUsers;
import com.aidex.quartz.domain.SysJobLog;
import com.aidex.quartz.service.ISysJobLogService;
import com.aidex.quartz.service.TaskService;
import com.aidex.system.service.ISysUserService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalTime;
import java.util.*;

/**
 * 定时任务调度测试
 *
 * @author ruoyi
 */
@Component("ryTask")
public class RyTask {
    private static final Logger log = LoggerFactory.getLogger(RyTask.class);
    @Autowired
    private SearchInfoService searchInfoService;
    @Autowired
    private ReptileService reptileService;
    @Autowired
    private SearchInfoDetailsService searchInfoDetailsService;
    @Autowired
    private CustomerService customerService;
    @Autowired
    private ISysUserService iSysUserService;
    @Autowired
    private TempShareService tempShareService;

    @Autowired
    private JinjianCodeService jinjianCodeService;

    @Autowired
    private BusinessSetService businessSetService;

    @Autowired
    private RxkOrderService rxkOrderService;


    @Autowired
    private PushRuleService pushRuleService;
    @Autowired
    private PushRuleUserService pushRuleUserService;
    @Autowired
    private RedisCache redisCache;
    @Autowired
    private TaskService taskService;

    @Autowired
    private TempShareRuleService tempShareRuleService;
    @Autowired
    private ISysJobLogService sysJobLogService;

    @Autowired
    private CustomerTestService customerTestService;
    @Autowired
    private MessageInfoService messageInfoService;

    public static void main(String[] args) {

    }

    public String ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
        return "sdfsdfsdf";
    }

    public void ryParams(String params) {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams() {
        System.out.println("执行无参方法");
    }

    public void reSetDaySort() {
        jinjianCodeService.deleteJinjianCodeByIds(new String[]{});
    }

    /**
     * 京东爬虫
     *
     * @throws IOException
     * @throws InterruptedException
     */
    public void taskReptileJd() throws IOException, InterruptedException {
        SearchInfo searchInfo = new SearchInfo();
        searchInfo.setStatus("0");
        searchInfo = searchInfoService.findOne(searchInfo);
        if (null == searchInfo) {
            return;
        }
        String keyword = searchInfo.getName() + searchInfo.getBrandName();
        List<String> stringList = reptileService.runReptileByJd(keyword);
//        for (String url : stringList) {
//            SearchInfoDetails searchInfoDetails = new SearchInfoDetails();
//            searchInfoDetails.setBrandName(searchInfo.getBrandName());
//            searchInfoDetails.setName(searchInfo.getName());
//            searchInfoDetails.setUnit(searchInfo.getUnit());
//            searchInfoDetails.setInfoId(searchInfo.getId());
//            searchInfoDetails.setUrl("https://" + url);
//            searchInfoDetailsService.save(searchInfoDetails);
//        }
        if (stringList.size() > 0) {
            searchInfo.setDetailsId("https://" + stringList.get(0));
        }
        searchInfo.setStatus("2");
        searchInfoService.save(searchInfo);
    }

    /**
     * 用户分配
     */
    public void taskCustomerShare() {
        Customer customer = customerService.findOne();
        if (customer != null) {
            Map<String, Object> params = new HashMap<>();
            if (!StringUtils.isEmpty(customer.getCityName())) {
                String[] area = customer.getCityName().split("-");
                StringBuffer cityName = new StringBuffer();
                if (area.length == 2) {
                    cityName.append(area[1].replace("市", ""));
                } else if (area.length == 1) {
                    cityName.append(customer.getCityName().replace("市", ""));
                }
                params.put("cityName", cityName.append("市").toString());
                params.put("laiyuan", customer.getLaiyuan());

                if (StringUtils.isNotNull(customer.getIsRep()) && 1 == customer.getIsRep()) {
                    params.put("userId", customer.getUserId());
                } else {
                    params.put("userId", null);
                }
                List<SysUser> sysUserList = iSysUserService.findShareUser(params);
                if (null == sysUserList || sysUserList.size() == 0) {
                    //没有可分配的用户了  表示一轮已经分完了
                    SysUser sysUser = new SysUser();
                    sysUser.setCity(params.get("cityName").toString());
                    sysUser.setBusType(params.get("laiyuan").toString());
                    List<SysUser> shareUserList = iSysUserService.findList(sysUser);
                    if (shareUserList.size() > 0) {
                        tempShareService.deleteAll(shareUserList);
                    }
                    //重新查询
                    sysUserList = iSysUserService.findShareUser(params);
                }
                //如果查询到用户列表取第一个用户 如果没有用户了，返回空用户
                SysUser user = sysUserList.size() > 0 ? sysUserList.get(0) : null;
                if (null == user) {
                    // 分给客户经理 找客户经理
                    List<SysUser> mSysUserList = iSysUserService.findUserByCity(params);
                    user = mSysUserList.size() > 0 ? mSysUserList.get(0) : null;
                    if (null == user) {
                        customer.setStatus(CustomerEnum.FP_SHIBAI.getStatus());
                        customer.setInfo("分配用户为空，用户经理为空！");
                        customerService.save(customer);
                    } else {
                        customerService.shareCustomer(customer, user);
                    }
                } else {
                    customerService.shareCustomer(customer, user);
                }

            } else {
                customer.setStatus(CustomerEnum.FP_SHIBAI.getStatus());
                customer.setInfo("城市信息为空！");
                customerService.save(customer);
            }
        }
    }

    /**
     * 每天 凌晨 重置日分配数量
     */
    public void taskResetDayShareCount() {
        iSysUserService.resetDayShareCount();
    }

    /**
     * 未接6小时流转（9.00-18.00），非工作时间不计入，三次未接流转  或的关系，有一个满足就流转  针对新客户，流转两次就不再流转，锁定的除外
     */
    public void taskWeiJieCustomerToShare() throws Exception {
        taskService.taskWeiJieCustomerToShare();
    }


    /**
     * 根据规则分配
     */
    public void taskCustomerShareByRule() throws Exception {
        // 读取配置参数
        BusinessSet businessSet = businessSetService.get("index_set");
        // 如果配置了任务执行时间 需要在时间内执行任务
        if (null != businessSet && null != businessSet.getIsNewShareOpen() && 1 == businessSet.getIsNewShareOpen() && null != businessSet.getNewShareStartTime() && null != businessSet.getNewShareEndTime()) {
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
            Date setTime = sdf.parse(businessSet.getNewShareStartTime());
            Date endTime = sdf.parse(businessSet.getNewShareEndTime());
            LocalTime now = LocalTime.now();
            // 定义时间段
            LocalTime startTime1 = LocalTime.of(setTime.getHours(), setTime.getMinutes(), setTime.getSeconds());
            LocalTime endTime1 = LocalTime.of(endTime.getHours(), endTime.getMinutes(), endTime.getSeconds());
            if (now.isAfter(startTime1) && now.isBefore(endTime1)) {
                Customer customer = customerService.findOne();
                String ruleType = "0";
                this.taskOneCustomerShareByRule(customer, ruleType);
            }
        } else {
            Customer customer = customerService.findOne();
            String ruleType = "0";
            this.taskOneCustomerShareByRule(customer, ruleType);
        }
    }

    /**
     * 根据重复规则分配
     */
    public void taskZhuangkuCustomerShareByRule() throws Exception {
        // 读取配置参数
        BusinessSet businessSet = businessSetService.get("index_set");
        // 如果配置了任务执行时间 需要在时间内执行任务
        if (null != businessSet && null != businessSet.getIsZkShareOpen() && 1 == businessSet.getIsZkShareOpen() && null != businessSet.getZkShareStartTime() && null != businessSet.getZkShareEndTime()) {
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
            Date setTime = sdf.parse(businessSet.getZkShareStartTime());
            Date endTime = sdf.parse(businessSet.getZkShareEndTime());
            LocalTime now = LocalTime.now();
            // 定义时间段
            LocalTime startTime1 = LocalTime.of(setTime.getHours(), setTime.getMinutes(), setTime.getSeconds());
            LocalTime endTime1 = LocalTime.of(endTime.getHours(), endTime.getMinutes(), endTime.getSeconds());
            if (now.isAfter(startTime1) && now.isBefore(endTime1)) {
                Customer customer = customerService.findZkOne();
                String ruleType = "2";
                this.taskOneCustomerShareByRule(customer, ruleType);
            }
        } else {
            Customer customer = customerService.findZkOne();
            String ruleType = "2";
            this.taskOneCustomerShareByRule(customer, ruleType);
        }
    }


    /**
     * 分配未接待流转客户
     */
    public void taskWeiJieCustomerShareByRule() {
        Customer customer = customerService.findWjOne();
        // 新客户未接流转只流转2次，后面不再流转
        // 修改客户累计分配次数
        if (null != customer) {
            if (null == customer.getIsRep() || customer.getIsRep() == 0) {
                if (null != customer.getShareCount()) {
                    customer.setShareCount(customer.getShareCount() + 1);
                } else {
                    customer.setShareCount(1);
                }
            }
            String ruleType = "0";
            this.taskOneCustomerShareByRule(customer, ruleType);
        }
    }


    /**
     * 每天 凌晨 重置日分配数量(规则分配)
     */
    public void taskResetDayShareCountByRule() {
        //分配用户每日接单数量重置
        pushRuleUserService.resetDayShareCount();
        //公海每日已分配数量重置
        this.taskResetGonghaiDayShareCountByRule();
    }

    /**
     * 每月一号重置累计分配数量(规则分配)
     */
    public void resetRuleUserTotalCount() {
        pushRuleUserService.resetRuleUserTotalCount();
    }

    /**
     * 根据规则分配(公海客户)
     */
    public void taskGonghaiCustomerShareByRule() {
        try {
            System.out.print("taskGonghaiCustomerShareByRule********************");
            String ruleType = "1";
            int updateCount = 0;
            String limitCountStr = ConfigUtils.getConfigValueByKey("rule.gonghai.daysharecount");
            if (StringUtils.isNotNull(limitCountStr) && StringUtils.isNotEmpty(limitCountStr)) {
                int limitCountMax = Integer.parseInt(limitCountStr);
                // redis记录拉取次数
                String updateCountKey = "customer:gonghai:updateCount";
                Object updateCountObj = redisCache.get(updateCountKey);
                if (null != updateCountObj) {
                    updateCount = (int) updateCountObj;
                }
                if (updateCount < limitCountMax) {
                    Customer customer = customerService.findGonghaiOne();
                    int result = this.taskOneCustomerShareByRule(customer, ruleType);
                    redisCache.set(updateCountKey, updateCount + result);
                }
            }
        } catch (Exception e) {
            log.error("调用taskGonghaiCustomerShareByRule:" + e.getMessage());
        }

    }

    /**
     * 根据规则分配用户的通用方法（包括待分配用户和公海用户）
     */
    private int taskOneCustomerShareByRule(Customer customer, String ruleType) {
        int result = 0;
        if (null != customer) {
            //待分配规则 转到我的客户
            if ("0".equals(ruleType) || "2".equals(ruleType)) {
                customer.setStatus(CustomerEnum.MY_CUS.getStatus());
            } else if ("1".equals(ruleType)) {//公海分配规则 转到线索池
                customer.setStatus(CustomerEnum.YI_FP.getStatus());
            }
            if (!StringUtils.isEmpty(customer.getCityName())) {
                String cityName = customer.getCityName();
                if (cityName.contains("-")) {
                    String[] area = customer.getCityName().split("-");
                    if (area.length == 2) {
                        cityName = (area[1].replace("市", ""));
                    }
                } else {
                    cityName = (cityName.replace("市", ""));
                }
                PushRule pushRuleParam = new PushRule();
                pushRuleParam.setRuleCities(cityName.toString());
                pushRuleParam.setLaiyuan(customer.getLaiyuan());
                pushRuleParam.setRuleType(ruleType);
                pushRuleParam.setStatus("0");
                this.shareRuleUser(customer, pushRuleParam, 0, 50);
            } else {
                customer.setInfo("城市信息为空，分配给南昌区域经理");
                this.shareToQyjl(customer, "南昌");
            }

// 锁定的不分配代码
//            if (0 == customer.getIsRep() || (1 == customer.getIsRep() && 1 == customer.getIsRepFen())) {
//                //待分配规则 转到我的客户
//                if ("0".equals(ruleType) || "2".equals(ruleType)) {
//                    customer.setStatus(CustomerEnum.MY_CUS.getStatus());
//                } else if ("1".equals(ruleType)) {//公海分配规则 转到线索池
//                    customer.setStatus(CustomerEnum.YI_FP.getStatus());
//                }
//                if (!StringUtils.isEmpty(customer.getCityName())) {
//                    String cityName = customer.getCityName();
//                    if (cityName.contains("-")) {
//                        String[] area = customer.getCityName().split("-");
//                        if (area.length == 2) {
//                            cityName = (area[1].replace("市", ""));
//                        }
//                    } else {
//                        cityName = (cityName.replace("市", ""));
//                    }
//                    PushRule pushRuleParam = new PushRule();
//                    pushRuleParam.setRuleCities(cityName.toString());
//                    pushRuleParam.setLaiyuan(customer.getLaiyuan());
//                    pushRuleParam.setRuleType(ruleType);
//                    pushRuleParam.setStatus("0");
//                    this.shareRuleUser(customer, pushRuleParam, 0, 50);
//                } else {
//                    customer.setInfo("城市信息为空，分配给南昌区域经理");
//                    this.shareToQyjl(customer, "南昌");
//                }
//            } else {
//                // 不分配，协助给经理
//                customer.setStatus(CustomerEnum.MY_CUS.getStatus());
//                //重复进线的信息发送给客户经理
//                JSONObject jsonObjectSocket = new JSONObject();
//                jsonObjectSocket.put("type", "fenpeiNewCus");
//                jsonObjectSocket.put("msg", "重复客户进线（不分配）-" + customer.getCusName());
//                WebSocketUsers.sendMessageToUserByText(WebSocketUsers.TYPE_PC, customer.getUserId(),
//                        jsonObjectSocket.toJSONString());
//                messageInfoService.sendMsg(customer, MessageTypeEnum.JRCFKH, jsonObjectSocket.getString("msg"));
//                if (!StringUtils.isEmpty(customer.getCityName())) {
//                    this.xieZhuToQyjl(customer, customer.getCityName());
//                } else {
//                    this.xieZhuToQyjl(customer, "南昌");
//                }
//            }
        }
        return result;
    }

    private void shareRuleUser(Customer customer, PushRule pushRuleParam, int depth, int maxDepth) {
        System.out.print("查找pushRule********************\r");
        PushRule pushRule = pushRuleService.getPushRule(pushRuleParam);
        if (null != pushRule) {
            pushRuleParam.setRuleSet(pushRule.getRuleSet());
            System.out.print("pushRule不是null********************");
            // 重复分配的客户不累计当日分配数量，同时不占用本次分配名额。
            //先都保存顺序 分配的时候去判断 删除临时表
            // 存储临时表
            TempShareRule tempShareRule = new TempShareRule();
            tempShareRule.setRuleId(pushRule.getId());
            tempShareRule.setLaiyuan(pushRuleParam.getLaiyuan());
            tempShareRuleService.save(tempShareRule);

            pushRule.setLaiyuan(customer.getLaiyuan());
            // 查找当前规则的用户 没有就两种情况 一是这一轮分完了 需要重置临时表 二是所有用户都达到了上限
            if ("1".equals(pushRule.getRuleSet())) {
                pushRule.setRuleCities(pushRuleParam.getRuleCities());
                pushRule.setLaiyuan(pushRuleParam.getLaiyuan());
            }
            List<PushRuleUser> pushRuleUsers = pushRuleUserService.findShareUserByRule(pushRule);

            if (null == pushRuleUsers || pushRuleUsers.isEmpty()) {
                // 这里只需要处理自定义分配。
                // 按人员分配 每个规则里就一个符合城市+来源的人 不需要判断是否一轮分完了 规则里没有就递归找下一个规则
                if ("2".equals(pushRule.getRuleSet())) {
                    PushRuleUser pushRuleUser = new PushRuleUser();
                    pushRuleUser.setIsEnable("1");
                    pushRuleUser.setRuleId(pushRule.getId());
                    List<PushRuleUser> shareUserList = pushRuleUserService.findList(pushRuleUser);
                    if (null == pushRuleUsers || pushRuleUsers.isEmpty()) {
                        //没有可分配的用户了  表示一轮已经分完了
                        if (!shareUserList.isEmpty()) {
                            String[] ids = new String[shareUserList.size()];
                            for (int i = 0; i < shareUserList.size(); i++) {
                                ids[i] = shareUserList.get(i).getId();
                            }
                            tempShareService.deleteAllByUserRuleIds(ids);
                        }
                        //重新查询
                        pushRuleUsers = pushRuleUserService.findShareUserByRule(pushRule);
                    }
                }

                // 若还是没用户 并且所有规则的用户还有剩余 就找下一个规则  否则表示都达到了上限 分给区域经理
                if (null == pushRuleUsers || pushRuleUsers.isEmpty()) {
                    List<PushRuleUser> pushAllRuleUserList = pushRuleUserService.findAllShareUserByRule(pushRuleParam);
                    if (null == pushAllRuleUserList || pushAllRuleUserList.isEmpty()) {
                        // 所有人数量达到上限 分给区域经理
                        customer.setInfo("当日分配用户已达上限，分配给区域经理");
                        this.shareToQyjl(customer, pushRuleParam.getRuleCities());
                    } else {
                        // 递归查找下一规则
                        if (depth < maxDepth) {
                            shareRuleUser(customer, pushRuleParam, depth + 1, maxDepth);
                        } else {
                            //"超出最大递归深度限制：" + maxDepth；直接分给区域经理
                            customer.setInfo("超出最大递归深度限制：" + maxDepth + ",分给区域经理");
                            this.shareToQyjl(customer, pushRuleParam.getRuleCities());
                        }
                    }
                } else {
                    PushRuleUser user = pushRuleUsers.get(0);
                    customerService.shareCustomerByRule(customer, user);
                }
            } else {
                PushRuleUser user = pushRuleUsers.get(0);
                customerService.shareCustomerByRule(customer, user);
            }
        } else {
            //2025-05-06 20:00 吴总同意 未匹配到规则的分给南昌区域经理 依琳
            customer.setInfo("未匹配到分配规则，分配给南昌区域经理");
            this.shareToQyjl(customer, "南昌");
        }
    }

    private void shareToQyjl(Customer customer, String city) {
        PushRuleUser qyjl = null;
        List<PushRuleUser> qyjlList = pushRuleUserService.findQyjlByCity(city);
        if (null != qyjlList && !qyjlList.isEmpty()) {
            Random random = new Random();
            int randomNumber = random.nextInt(qyjlList.size());
            qyjl = qyjlList.get(randomNumber);
        }
        if (null == qyjl) {
            if (!"南昌".equals(city)) {
                customer.setInfo("分配用户为空，" + city + "用户经理为空,分配给南昌经理");
                this.shareToQyjl(customer, "南昌");
            } else {
                customer.setStatus(CustomerEnum.FP_SHIBAI.getStatus());
                customer.setInfo("分配用户为空，南昌经理为空！");
                customerService.save(customer);
            }
        } else {
            customerService.shareCustomerByRule(customer, qyjl);
        }
    }

    private void xieZhuToQyjl(Customer customer, String city) {
        List<PushRuleUser> qyjlList = pushRuleUserService.findQyjlByCity(city);
        if (null != qyjlList && !qyjlList.isEmpty()) {
            for (PushRuleUser qyjl : qyjlList) {
                customerService.xieZhuCustomer(customer, qyjl);
            }
        } else {
            if (!"南昌".equals(city)) {
                customer.setInfo(city + "经理为空,协助给南昌经理");
                this.xieZhuToQyjl(customer, "南昌");
            } else {
                customer.setStatus(CustomerEnum.FP_SHIBAI.getStatus());
                customer.setInfo("分配用户为空，南昌经理为空！");
                customerService.save(customer);
            }
        }
    }

    /**
     * 每天 凌晨 重置公海日分配数量(规则分配)
     */
    private void taskResetGonghaiDayShareCountByRule() {
        String updateCountKey = "customer:gonghai:updateCount";
        Object updateCountObj = redisCache.get(updateCountKey);
        if (null != updateCountObj) {
            redisCache.set(updateCountKey, 0);
        }
    }


    /**
     * 定时获取 融360的数据 每2分钟一次 南昌
     *
     * @param
     */

    public void taskGetRong360() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId = "5002409";
        // 融360分配的密钥, 注意不能删除回车和空格, 上线时替换
        String privateKey =
                "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAPpZ7nf7nj6s50Jv" + "NCj3DxVMWk3rUwMpGd" + "+Ze" +
                        "/kRrogXhYpRl7uCndRU+f27m2r9zGPBobfCA5f8H9jK" +
                        "9Kerm4qtu1ImmWzJhmJ08ZwChcAJPXDiFwyOWcq8gKI7bSM" + "+waa2bnaLUHpaifNb" + "3KvIoytroimz" +
                        "+HAqsZZBlUlHjCnhAgMBAAECgYB+GxbYMVLA12+WM1Xe3LQoUlGa" + "tlMWYHm7" + "/CBKkfGMc+y8g+Ueeujtr" + "/BNM1dSSY3PIhZH7d7JjCKunW0nmHW8IkDl" + "y96Y5IFMFdZZ3cbe215BbXRSy7oDgLfjyK5nhNroVh5IcVTcoR" + "+nbPEdUnM4XRTf" + "aJbdYY2fiYbF7ltnEQJBAP940" + "/jJCDyEXx2FgYM9ZSPqUk1Ck92z3V4anbCzd+hQ" + "gvYDaF4ETqSJnk5LdOPUKx2wLdQgiI" + "/4WVeeSp3OBTsCQQD63mTke2UN2AosIcDR" + "+UBrUXgisojhrtXtnjhmuep3lRzLoHNFW7IxrAStlxcqKbXDb4uLDP52UKIitjND" + "NuuTAkEA5auUtWbV1sISWJH7mycI1D8GeprOIFRhQQagmYje1aX79nudylgI83cd" + "MLo5fdDyaiBHMxuEahoVB" + "+YwoqninQJAMxwsIgChzfg92k/mIOFPJo4qk6ccDB66" + "pvadNxCZnFNc0n+V/IN6AnSxX0xxA74Lsg1" + "/uIylKyWyYrAMMZ120QJBALPBg4gf" + "/NHen7+PBQeQdeCQenTvmFYhvSO5QLWJfpnIDovxKQ83kJX99Qb4d7KrZtISjwN1" + "g297T9TiGljZa0A=";
        //融360分配的总账号ID, 联调时替换
        String uid = "864201";
        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }


    }


    /**
     * 定时获取 融360的数据 每2分钟一次 上饶
     *
     * @param
     */

    public void taskGetRong360ShangRao() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId = "5002205";
        // 融360分配的密钥, 注意不能删除回车和空格, 上线时替换
        String privateKey = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAMJF8wR1ChyXVnEd" +
                "T7M2UClrPk35VpRpmfGPW483tTl6/h2JN/ivikPooFCA7dsBalHerwBNiz0Sb85E" + "kJ" +
                "+tZNJaqzJnkYhmkAloZ7DcnyqrIaq5MTWUj71G1iAt5bsaUj0GJE7RtWqBPXHc" +
                "15TFL1XTyR4zv3WL8o13FScWcxWdAgMBAAECgYEAnAZFqHy/BDtfBzV9PvcN5lXl" + "EgaATG2LX3" +
                "+9Dwa0m1d2Iw6DT0zcBLIdnsoNPWijlOD9N4cPnpriBIz4geVmJExt" + "RGAXcxVULaL4Sz8DgUT6c3UuZ0K48MLFENKN7" +
                "/Mje193hbl6P0IXpGT+57mW42YZ" + "95aTLPkyKt+67tNAetkCQQDpS5RcYvhHu5YX6ItXGr/qlpxSDnaiJnFM6tmS2wXl" +
                "tSY/FgYxBp6ZkytLiJgsaH9zYsU01h7ynhxNssjZKlLrAkEA1S4omKkG8sv+FQXS" +
                "z8EYmcBGCVpipXwfQpWvX4tfKPt0FuAwUsjh2UEW2dI1N+0cSxv454NT35icxVFf" + "EzdHlwJBAIxunH4IbV" +
                "/wwWbe6pGiXog95RdX8X2mGmmsrQ/DnAcsRjuPbGayj2Hu" + "vw8WyFNjC+VPPVqS0cpF9s" +
                "+moVRoL8UCQElj5LH5rtyzgbt3D8ZaMb/sw6/AoClc" + "e96ObZu0/YO8XZDqiXhWk" +
                "/oZQGaoyY2BYbYx4RTCz4MwpPgBNXwGEe0CQQCzIZoP" + "70Phi1tV16ZJ+OZnSMxBiZ3/rnqNu8yRSDZKoCVvxZ5Pjh27" +
                "/iOlQNEoRck+UTOt" + "a6zdqcRAQ3gJgS89";
        //融360分配的总账号ID, 联调时替换
        String uid = "862669";
        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
//        System.out.println(service.getorderlist(params));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }
    }

    /**
     * 定时获取 融360的数据 每2分钟一次 吉安
     *
     * @param
     */
    public void taskGetRong360JiAn() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId, uid, privateKey;
        appId = "5002270";
        uid = "863220";
        privateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANsUvRrVJLjOa/Px" +
                "RtApl8EPXp9ZojhDkrbDiwYiRoSddGvAW6PUVG6+piBGSP/2+q4fjeJ6nbt/y1vp" +
                "HOM3yIMrieaZprlKEyP1mCixu0mw2necXb2/4TFBtzioQR7X9a0/jAVy2ovi7l4F" +
                "Q6HuPIeMVLwVbkA1dDikFrMD1mGtAgMBAAECgYEAzb8QSd7aeeUCZTq28k/dgSZa" + "CvU27/gmFRZXvg76gxkMeRVR+u4xzT" + "+m7LCVZi4hBt4DdisJb0l5RnwK8Sk2WJzb" + "LIAdOMtPo1NoeiCVu" + "/0k9hrXic4UrunPEA4C9d6jSy0lxxHT2gduPRiJVZ7oAcL2" + "Nb1KU441umQZUlm9cIECQQDyoNfUvGxblKtAPH9oMNVmMNcofJmQZLDueGDWpe/1" + "+VmlcD42OyjlrjXg9OrXqtUw2cUL2eJENemOR52bSkGVAkEA5yes4KjHUHQP6czO" + "VZqByg0nqnGAZmVnhmn540M4ubffZ4bbFj6bfjCD88QZkGXwANb70H8NCEfn/fw+" + "eTPJuQJAVfuMITbZC6dm/O+zkv" + "/jUEC0rwNhBFu6m/gLEWZi4H+KNmfNlDho6ORQ" + "8bS52M4QmSxDeUyws82LREG658Jr9QJBAOZwYSHeYETOT4buy8v" + "/KeB52M9MM4rh" + "EKGpSJrNSuGqcqbMg+DbLTxRtVnwZuPTG75ak9M4tY9Jz/cd3lIJ1NECQCwnJBYr" + "iZ8cAoQ" + "/Ko2fGbuJT0VAKuVgHjfw9ineguRrhjEj8dS6uWnKspM6rFAllhQaQQ5t" + "JoekbJ16KwAqYBQ=";
        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }
    }

    /**
     * 定时获取 融360的数据 每2分钟一次 宜春
     *
     * @param
     */
    public void taskGetRong360YiChun() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId, uid, privateKey;
        appId = "5002803";
        uid = "867932";
        privateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMMTqvkHusHWa4Gn" +
                "15GB4BQTu794WpGdvkcT4SuYpQVBaIJVA1TN7byXTIWyEQpGEqQdweB5dNEIuuuJ" + "2+f0ttPieXnp" +
                "+scy3JpUiqnoFCpNGSAVJBjHmyM1Rq1q9X1w9lvegUcukVxRKZ0M" + "25DquO3nmAY471en9hyA/Cc" +
                "/vlYFAgMBAAECgYEAtsoaHaj5fSIOsHn2S1jX/9gR" +
                "x7Ldoq6dmfptti0dC9SjOeSw72jaiCl5QZl90BOi6fccMNt981Tr2ULfNPUfzbp5" + "NOY7OwqAvuv" +
                "/d0rlV7qf1JzKnmKoG34Tnbp0WFD32QAobYc92d+wChE3yjpbhCQO" + "yYvZcpUKaElErO2XFU0CQQD" +
                "+sdibq3y5zEhwzGY0gXOPL45U4r6MpNzHgcee+b66" + "+TkXkPFKKC008IKVix5n1TJz4aeRpkKQauYTFbZ5l" +
                "//LAkEAxBOauLmyl90PFPy+" + "qXgypnxYuUrficD+UiAk/auvR+2tnSHx99tKhqgCpyn67wUsCi0UzzOT/L86qobY" +
                "e8unbwJBAIb8Xx7yHmKioGoYCrsdOM/Ulozqt6722YRrhg79slaKK/YPfbKd5IfA" + "SJVVbEH" +
                "/voOoPxV0lqbP4SyQP2vmYU0CQHX4saOpHtoeR//BndmLFzZyJFO/x8Uz" +
                "GBFDg94YWQq25zlefh45k5p3Jbl8GZ2MCBZLT3TnPIfaaqrFHSVGwAMCQF7RtFam" + "tOdGYjNe3" +
                "+6xddZ3o3nWtI9YllE5x3qGV/4XemM1AB185qlEd45Bvq+Pq9qOZIdG" + "B3AGj/E2CNjilzI=";

        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }
    }

    /**
     * 定时获取 融360的数据 每2分钟一次 抚州
     *
     * @param
     */
    public void taskGetRong360FuZhou() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId, uid, privateKey;
        appId = "5002272";
        uid = "863203";
        privateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAOhPrQdKPfeJTIr1" + "pY049H7AUIkw5RtJAFDlIx" +
                "+5hPAueULHWfTv6zVwlMt9YQF0kZA4Z9FESWm0qzL7" +
                "0LlpRqpdPqSClhA9L4yExtm47Pbmcmer50b4g41qI8tfFjWYeFdgsngtbI4wqdv3" +
                "SsbxPgQ9sl9aCl6jrSNG2fDCOJcpAgMBAAECgYAEcCE6Fm0AoZrYvMCg5gmlsj7X" +
                "oBuAXfCnmvkEziKABCNE51IMn9i6eKAfExIbWQK+4pT5JnjQkCcFHlJqeFxlM3it" +
                "dx4UcrmkxZaIWaGxjSYYe1qi3LX3ysbWPjoxBJSSXSjQK4zx6CIiPHlp2Z8oq1Qa" + "eHN2I" +
                "/DdlBaqa7y20QJBAPpPZWFBZjmFWmJZ7tX/ri28ZvP8VKgDuqppUb1jxGtl" +
                "OU3b3hjTkt2HkLSR3n1iGGnjCqZDe4Bkuw23AWqeJR8CQQDtl4prCLBkkPGtm/V8" + "RciMnfNV8319UEhff2DglfhhGD2eDE" + "+T9exh2QRjgnOw/p9BP9T/ch1Uj0DE8iqO" + "lDK3AkB7mzd6BlyfrQ2MIdMCVEdECJRiicmYSnckbevSdXDqg8r/esK7Scdto" + "+M+" + "eAYBrq5Vo6t/nTVgmt2QET4e00eLAkEA2a6HTouWeX1nQGXs4+BX36XzxaMiLYc5" + "1+0vyHT" + "/LY51HfIvkuO1oOyhnb5u2xJevPyL3UMjZk8dy5QIs7tKPwJBAL5LNKud" + "bxVPOO" + "+jJ1Q1hsDZQGS5G63Isjxo0Pvc1XQLs4Pxg3P/1vBywNwDZJhXcz0LgIga" + "TZj9kItOvx1mx60=";
        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }
    }

    /**
     * 定时获取 融360的数据 每2分钟一次 九江
     *
     * @param
     */
    public void taskGetRong360JiuJiang() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId, uid, privateKey;
        appId = "5002273";
        uid = "863202";
        privateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAOsRASgqYOhzKtZA" + "/5fd1PmIFzm" +
                "/G3hmMqIvy3jVg7awrqWlLkLqynEnt3qkhGiPlIrtCyUW84fqyx9G" + "9PUTapMWVFojCKNYxSlZjLV5agqHUz5EEDpjsfU4o" + "/GKUguJPZAQ/sbwlMi7gm8K" + "hxyvDLehnAh156ouDtgvoqPK3fzvAgMBAAECgYEA3XVMwLmESRrPXcEoy7vrfRdw" + "wi" + "/AwqKNy2z55iJKD+DO+THwroyjIw4G9x1tvVCf4m7GlC/WSdOzgAkKmKWtPY2H" + "q2hAB2pnIX+jQpS4cLqxmIG/eaus" + "+mNRhhUTa+086xSmiJHac+eLzQ0n/l7wxZtQ" + "CwDQ3b12gBRAZTwDmJkCQQD4I8/9bMt5KvSHA8knGg4yjK3hdl" + "+TuHFH9LjNgkp8" + "hu6YLQVGMWyZLL5umIZGypacfRn4nGlK4PwNW4KrfoYVAkEA8oMtnbbxv4qiMCyP" + "oPU03DK2kPbOnRTPR6baV5zYyLY/e2RBAs1QOecusADur0c/TsrUEO/tMdLZH/EK" + "F76b8wJABdxysT28oKQPGpFQUwgehbsk8Epnf4m/wz9YjiIhuEdHo3iMw1evhP61" + "kM8xfMKURCYAUwr" + "+wbIGwhoDQCHA8QJBALxRBvwgkutFMRqtj77SioCvVLuPG/Q4" + "s5kVRRmhr2l0tCkSObV+T10XW1bK8o3jipKZyEF6vjrhWz" + "+Fgmvb1OcCQHVjY8xz" + "3M+UdWMq5mCpVZqc7Uk0gwWuodv7i4YeA5A9JB5ERlBNueUv1uSzFWA5JCvK1zwE" + "8WCnGTPQbilju3Y=";
        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }
    }

    /**
     * 定时获取 融360的数据 每2分钟一次 赣州
     *
     * @param
     */

    public void taskGetRong360GanZhou() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId = "5002343";
        // 融360分配的密钥, 注意不能删除回车和空格, 上线时替换
        String privateKey =
                "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBANYsKTKFGDkm4xgm" + "JKDoEIpvI5qgvHR0dv" +
                        "/Mx2ope2nItjMnXU3VEdN3lVW8VmCeIKRigJQUfkYEqNOH" + "ucHNVM3X6nh+BBLnGEj3Q963SWpf9wLuY" +
                        "+ErrnRpo0kSIs7jvJf/4/Ln21dEBG3W" + "K8O" +
                        "+VSMffziyH7L2SHV0gMk0e1JRAgMBAAECgYAHMIRRhdZCVOPas60XGbM0cnan" +
                        "gi3RWveDrsQi9DGIY4x6OyAOtNBcYO9KaYAczjIaUpQuZGG4x/9C2pOJxfLKxmmz" + "zpb4gtnMmlypsY" +
                        "/7riD0N6oAQbYz3mw8GzzHFGxQf1UaQmy3itZgqOGyOR7km/sC" +
                        "5LFwzEQAavrdPb5GAQJBAPu2Zuox3UzOb1CynpQTay49aZCmbySP8lermVzGD8tw" +
                        "SqjUChd1rYXaqv5rd3PUHvTradPeknJcVa5vFiTbJakCQQDZ0hCczpci3P9VblXB" + "RTZWbA" +
                        "+FC6aoWIGILlDRL8sOmBBoGQiFHNLBMqnLYA2Xo7lb9a9AbSv0AP1y1hh1" +
                        "neBpAkAPxDAUEUWETxXn3xhRvBmljtEy70nc52tNlIEJr5pDqufyRT3QlF1nGfhF" + "8WNNDQdXXfuF+tX" +
                        "/dcskHu8rJdLpAkB0eEmfvyu7XZY+NSAvlvWmImPuDTvQ+npQ" + "ugtGv5qBNDhZoUEYBECBQ7jc4YCDG" +
                        "+2KSYWrGnUNJNZg6C" + "/t/Dw5AkEA5aO92mDU" + "FApf1sUzmvYvB8pxkFksIuxsiyF7QZJAzF4E4jU" +
                        "+vPy8rV8VkL1kAUr5RE5MCrSp" + "FHwsUqFN1+YAwg==";
        //融360分配的总账号ID, 联调时替换
        String uid = "863208";
        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
//        System.out.println(service.getorderlist(params));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }
    }

    /**
     * 定时获取 融360的数据 每2分钟一次 宁波
     *
     * @param
     */

    public void taskGetRong360NingBo() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId = "5002658";
        // 融360分配的密钥, 注意不能删除回车和空格, 上线时替换
        String privateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAM041fAdCZi6Hd6p" +
                "yW6sETPw5g0efNKgRaSodr9q0zXQcX5F8HzrbzgA7hEG9CS3Q9CVmiCBigv8i7kI" +
                "VKOc3giQAYkBCMC9GokpHcJ9bHnb1bO7mmh7ZMJsu6u9JhcWxKtEvyGlEKD1TcLb" + "7HUEnyJYMnqkDIR" +
                "+Waa3ptPy1k6RAgMBAAECgYBYsYukrqgLHcTzCqZH8o2syRxj" + "5x1DWok+1KAdsml+BIxIaqm5E3eJ2L0LFtpFU/83ErD" + "+A35KF+e7HGKYI5/BhFeT" + "ngdO/VO7+wiHeZRdSPVl/AwH0C02MBOsec2941pTxLHo8krLq9QZajjg3wh3yC7R" + "RdINBtI2vcRbmCZzEQJBAP8qXP+ytnoxjk8dlqHtNsj5Eq/+VX22UwOtVbzEWvvh" + "OAO5ncm2gl6FLLqGmHj8epNffjPv3bhuGEDhgjfD9S8CQQDN5KhI9w6FjT9osTn5" + "Za0Gwy" + "/WRAGr91WoYR8blcMJWi9UyDiDEYrhQs8M81904grby0W25+Dc/iAENbT3" + "ZIg/AkEAoSZyIZMOp9GQXOsE7TNRfE" + "/Bu6DXAVQazaG1GkiwZY9xvviFbJV1dJiL" + "DSpgNVjPWS/gFpEQ6J+vdZp2kR2TRQJAJZ1hlTr1fzan3" + "/OI2ORXcQXVxnpUJ9ue" + "3Y0oxrxcjmfYf8+4a1GYIsE23HHV/Z+SRkdjrB++uAEBTmOVdSD7twJBAJ6uv5VO" + "R5v7elyUjziJPSLqyU4OoxkN83KYCWExzNE7rPBg9Q/o0BALz0gSemDcWnSb/Ouo" + "TnTwycFFOWH9QAI=";
        //融360分配的总账号ID, 联调时替换
        String uid = "866789";
        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }
    }

    /**
     * 定时获取 融360的数据 每2分钟一次 新余
     *
     * @param
     */

    public void taskGetRong360XinYu() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId = "5002765";
        // 融360分配的密钥, 注意不能删除回车和空格, 上线时替换
        String privateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKXFhW87+HwbZaXV" +
                "wPULf4WlRTpc5HsIGf9ddb4jTTCS/eFxVuYeKNlod00INa7Poecd1EXemReVLZnv" + "h0xRmYw5fiQb44UrF4wE9YOdoXK" +
                "//fZp0xGlE62FSwygf0PjmRbLnj8U8kbU9IRj" + "BsNPIuIfwc3cCja/FENEXkGefjY/AgMBAAECgYB4clYLhmV7t2RZ5D" +
                "/5TEtxza3J" + "RCl3A2HwW/XrGzdArezt2y4qsYs4vGDChc6Ln62hgdj0k1JlAi1KBfImj7uiLbkn" +
                "bmARTiJHaiAeXi8ZwCOAop+PKKUvK1mJcF+sINotna12t1tNrmgUq9FwQA/IpU0s" + "3I9" +
                "/dw2BkDoAgEoWQQJBANSb9Q6nRp3yW0I/KHvtJ2PYexcbqUc+whZ1FZSS5PER" + "cDlybgSJrygizyKn3te/3byJE5jx" +
                "/SKA2elCqYez+i8CQQDHmniOeBqQAfJy/2zv" + "jEZf/+5GS+sy2mpAsbRJUsiCkLDXE5F4kLxaPkc+8KY+7/bjP9r" +
                "+SgS9ay8iS5lS" + "71DxAkB+Sw4s4CzQkjCnj4Dq7Jsjcmrb9TB/A8ajNHXXRdL9aFBzr4eu5mLHwrWs" + "bm" +
                "+vVWfQINUlW0n0/vly2Ih/9ec9AkEAglnnpyraNfd/jQgv7RSPlPv/cJr9w10O" +
                "DKfAlC3i0hmJ0zttQe5LgyeuwXTJLMrrUacO7ggKpmUMB/qU66tsEQJBAIlpkl7B" +
                "ABd14SWlqIFpLi4vfcrxf2djYOoh5pqGiFiOKz3SPdP6Ryqc46VGcFLLNKYX13O2" + "H2+A74fjINqj3b4=";
        //融360分配的总账号ID, 联调时替换
        String uid = "867661";
        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }


    }

    /**
     * 融享客
     */
    public void taskGetRxkOrderCustomers() {
        RxkOrder rxkOrderparam = new RxkOrder();
        rxkOrderparam.setStatus("0");
        RxkOrder rxkOrder = rxkOrderService.findListByStatus(rxkOrderparam);
        if (null != rxkOrder) {
            String get_url = "https://gw.youxinsign.com/rxk-saas/api/organ-clue-api/readClues";
            String voucherCode = "3AIIJYJMI3UHVS5D";
            String key = "5BPZ3OLV41U8HB5L";
            String orderNo = rxkOrder.getOrderNo();
            JSONObject params = new JSONObject();
            params.put("voucherCode", voucherCode);
            params.put("orderNo", orderNo);
            JSONObject jsonObject = JSONObject.parseObject(HttpUtils.doPost(get_url, params));
            if ("1".equals(jsonObject.getString("code"))) {
                if (StringUtils.isEmpty(jsonObject.getString("data"))) {
                    return;
                }
                JSONArray customerJsonList = JSONObject.parseArray(RAESUtils.decrypt(jsonObject.getString("data"),
                        key));
                for (int i = 0; i < customerJsonList.size(); i++) {
                    JSONObject customerJson = customerJsonList.getJSONObject(i);
                    if (null != customerJson) {
                        rxkOrder.setStatus("1"); // 读取成功
                        Customer customer = new Customer();
                        customer.setLaiyuan("融享客");
                        customer.setClueId(customerJson.getString("orderNo"));
                        customer.setCusCanal(customerJson.getString("source"));
                        customer.setCusBody(customerJson.getString("cstSource"));
                        customer.setCusName(customerJson.getString("name"));
                        customer.setAge(customerJson.getInteger("age"));
                        customer.setRemark(customerJson.getString("productName"));
                        customer.setPhone(customerJson.getString("phone"));
                        customer.setSex(customerJson.getInteger("sex") == 0 ? "女" : "男");
                        customer.setCityName(customerJson.getString("city"));
                        Optional.ofNullable(customerJson.getInteger("profession")).ifPresent(v -> {
                            switch (customerJson.getInteger("profession")) {
                                case 200:
                                    customer.setWorks("上班族");
                                    break;
                                case 300:
                                    customer.setWorks("自由职业");
                                    break;
                                case 400:
                                    customer.setWorks("企业主");
                                    break;
                                case 500:
                                    customer.setWorks("个体户");
                                    break;
                                case 800:
                                    customer.setWorks("公务员");
                                    break;
                                case 900:
                                    customer.setWorks("其他");
                                    break;
                            }

                        });

                        Optional.ofNullable(customerJson.getInteger("incomeMonth")).ifPresent(v -> {
                            customer.setIncomeMonth(customerJson.getInteger("incomeMonth") + "");
                        });


                        Optional.ofNullable(customerJson.getInteger("loanUse")).ifPresent(v -> {
                            switch (customerJson.getInteger("sesameScore")) {
                                case 0:
                                    customer.setSesameScore("无芝麻分");
                                    break;
                                case 10:
                                    customer.setSesameScore("600分以下");
                                    break;
                                case 20:
                                    customer.setSesameScore("600~650分");
                                    break;
                                case 30:
                                    customer.setSesameScore("650~700分");
                                    break;
                                case 40:
                                    customer.setSesameScore("700分以上");
                                    break;
                            }

                        });
                        Optional.ofNullable(customerJson.getString("loanMoney")).ifPresent(v -> {
                            customer.setAmount(customerJson.getString("loanMoney").substring(0,
                                    customerJson.getString("loanMoney").indexOf(".")) + "万元");
                        });

                        Optional.ofNullable(customerJson.getInteger("loanExpiresMonth")).ifPresent(v -> {
                            customer.setLoanExpiresMonth(customerJson.getInteger("loanExpiresMonth"));
                        });

                        Optional.ofNullable(customerJson.getInteger("loanUse")).ifPresent(v -> {
                            // 有值的处理逻辑
                            switch (customerJson.getInteger("loanUse")) {

                                case 10:
                                    customer.setLoanUse("消费贷");
                                    break;
                                case 20:
                                    customer.setLoanUse("结婚贷");
                                    break;
                                case 30:
                                    customer.setLoanUse("购房贷");
                                    break;
                                case 40:
                                    customer.setLoanUse("装修贷");
                                    break;
                                case 50:
                                    customer.setLoanUse("购车贷");
                                    break;
                                case 60:
                                    customer.setLoanUse("教育贷");
                                    break;
                                case 70:
                                    customer.setLoanUse("旅游贷");
                                    break;
                                case 80:
                                    customer.setLoanUse("医疗贷");
                                    break;
                                case 90:
                                    customer.setLoanUse("其他贷");
                                    break;
                            }
                        });

                        Optional.ofNullable(customerJson.getInteger("gjjScop")).ifPresent(v -> {

                            switch (customerJson.getInteger("gjjScop")) {
                                case 0:
                                    customer.setAccumulation("无公积金");
                                    break;
                                case 10:
                                    customer.setAccumulation("缴纳未满6个月");
                                    break;
                                case 20:
                                    customer.setAccumulation("缴纳6个月以上");
                                    break;
                            }
                        });


                        Optional.ofNullable(customerJson.getInteger("sbScop")).ifPresent(v -> {

                            switch (customerJson.getInteger("sbScop")) {
                                case 0:
                                    customer.setSocial("无社保");
                                    break;
                                case 10:
                                    customer.setSocial("缴纳未满6个月");
                                    break;
                                case 20:
                                    customer.setSocial("缴纳6个月以上");
                                    break;
                            }
                        });

                        Optional.ofNullable(customerJson.getInteger("house")).ifPresent(v -> {
                            switch (customerJson.getInteger("house")) {
                                case 0:
                                    customer.setHouseType("无房产");
                                    break;
                                case 10:
                                    customer.setHouseType("有房产，不抵押");
                                    break;
                                case 20:
                                    customer.setHouseType("有房产，可抵押");
                                    break;
                            }

                        });

                        Optional.ofNullable(customerJson.getInteger("car")).ifPresent(v -> {
                            switch (customerJson.getInteger("car")) {
                                case 0:
                                    customer.setCarStatus("无车产");
                                    break;
                                case 10:
                                    customer.setCarStatus("有车产，不抵押");
                                    break;
                                case 20:
                                    customer.setCarStatus("有车产，可抵押");
                                    break;
                            }

                        });

                        Optional.ofNullable(customerJson.getInteger("baodanScop")).ifPresent(v -> {

                            switch (customerJson.getInteger("baodanScop")) {
                                case 0:
                                    customer.setBaodanScop("无保险保单");
                                    break;
                                case 10:
                                    customer.setBaodanScop("缴纳未满1年");
                                    break;
                                case 20:
                                    customer.setBaodanScop("缴纳1年以上");
                                    break;
                            }
                        });
                        Optional.ofNullable(customerJson.getInteger("credit")).ifPresent(v -> {

                            switch (customerJson.getInteger("credit")) {
                                case 0:
                                    customer.setZx("无信用记录");
                                    break;
                                case 10:
                                    customer.setZx("信用良好无逾期");
                                    break;
                                case 20:
                                    customer.setZx("2年内逾期少于9次无90天以上逾期");
                                    break;
                                case 30:
                                    customer.setZx("2年内逾期少于9次有90天以上逾期");
                                    break;
                                case 40:
                                    customer.setZx("2年内逾期大于9次");
                                    break;
                                case 50:
                                    customer.setZx("半年内有60天以上逾期");
                                    break;
                                case 60:
                                    customer.setZx("半年内无60天以上逾期");
                                    break;
                            }
                        });
                        Optional.ofNullable(customerJson.getInteger("isLoans")).ifPresent(v -> {
                            switch (customerJson.getInteger("isLoans")) {
                                case 0:
                                    customer.setIsLoans("无微粒贷");
                                    break;
                                case 10:
                                    customer.setIsLoans("1~2千");
                                    break;
                                case 20:
                                    customer.setIsLoans("2~5千");
                                    break;
                                case 30:
                                    customer.setIsLoans("5千~1万");
                                    break;
                                case 40:
                                    customer.setIsLoans("1万以上");
                                    break;
                            }
                        });
                        Optional.ofNullable(customerJson.getInteger("manageYears")).ifPresent(v -> {
                            switch (customerJson.getInteger("manageYears")) {

                                case 10:
                                    customer.setManageYears("1年以下");
                                    break;
                                case 20:
                                    customer.setManageYears("1年至5年");
                                    break;
                                case 30:
                                    customer.setManageYears("5年以上");
                                    break;

                            }
                        });
                        Optional.ofNullable(customerJson.getString("turnover")).ifPresent(v -> {
                            customer.setTurnover(customerJson.getString("turnover"));
                        });
                        Optional.ofNullable(customerJson.getString("turnoverPublic")).ifPresent(v -> {
                            customer.setTurnoverPublic(customerJson.getString("turnoverPublic"));
                        });
                        Optional.ofNullable(customerJson.getInteger("workingYears")).ifPresent(v -> {
                            switch (customerJson.getInteger("workingYears")) {
                                case 10:
                                    customer.setWorkingYears("0~6个月");
                                    break;
                                case 20:
                                    customer.setWorkingYears("6~12个月");
                                    break;
                                case 30:
                                    customer.setWorkingYears("12个月以上");
                                    break;
                            }
                        });
                        Optional.ofNullable(customerJson.getInteger("registAddress")).ifPresent(v -> {
                            customer.setRegistAddress(customerJson.getInteger("registAddress") == 10 ? "本地" : "外地");
                        });
                        Optional.ofNullable(customerJson.getInteger("hasBusinessLicense")).ifPresent(v -> {
                            switch (customerJson.getInteger("hasBusinessLicense")) {
                                case 0:
                                    customer.setHasBusinessLicense("未注册");
                                    break;
                                case 10:
                                    customer.setHasBusinessLicense("注册1年以下");
                                    break;
                                case 20:
                                    customer.setHasBusinessLicense("注册1至5年");
                                    break;
                                case 30:
                                    customer.setHasBusinessLicense("注册5年以上");
                                    break;
                            }
                        });

                        Optional.ofNullable(customerJson.getInteger("creditCard")).ifPresent(v -> {
                            customer.setCreditCard(customerJson.getInteger("creditCard") == 0 ? "无信用卡" : "有信用卡");
                        });
                        Optional.ofNullable(customerJson.getString("apiSourceName")).ifPresent(v -> {
                            customer.setApiSourceName(customerJson.getString("apiSourceName"));
                        });
                        Optional.ofNullable(customerJson.getString("followUserName")).ifPresent(v -> {
                            customer.setFollowUserName(customerJson.getString("followUserName"));
                        });
                        Optional.ofNullable(customerJson.getString("brand")).ifPresent(v -> {
                            customer.setBrand(customerJson.getString("brand"));
                        });

                        Map map = customerService.savePushCustomer(customer);
                        if (map.get("code").equals("200")) {
                            String return_url = "https://gw.youxinsign" + ".com/rxk-saas/api/organ-clue-api" +
                                    "/updateClueStatus";
                            params = new JSONObject();
                            params.put("voucherCode", voucherCode);
                            params.put("orderNo", orderNo);
                            params.put("status", 1);
                            params.put("remark", map.get("message"));
                            JSONObject.parseObject(HttpUtils.doPost(return_url, params));
                        }
                    }
                }
            }
        }
    }

    /**
     * 业务设置 定时任务-处理自动成为成交客户 每天凌晨1点
     *
     * @param
     */
    public void taskBusinessSettingByCjCustomer() {
        // 读取配置参数
        BusinessSet businessSet = businessSetService.get("index_set");
        if (null != businessSet) {
            JinjianInfo jinjianInfo = new JinjianInfo();
            switch (businessSet.getJinjianStatusValue()) {
                case "yfk":
                    jinjianInfo.setIsFk("1");
                    break;
                case "jjz":
                    jinjianInfo.setStatus("1");
                    break;
                case "dfk":
                    jinjianInfo.setJinjianStatus("1");
                    break;
            }
            customerService.updateStatusByJinJianStatus(jinjianInfo);
        }

    }

    /**
     * 业务设置 定时任务-取消锁定客户 每天凌晨2点
     *
     * @param
     */
    public void taskBusinessSettingByCancelLockCustomer() {
        // 读取配置参数
        BusinessSet businessSet = businessSetService.get("index_set");
        if (null != businessSet) {
            BusinessSetBo businessSetBo = null;
            // 取消锁定
            businessSetBo = new BusinessSetBo();
            businessSetBo.setTime(businessSet.getManagerLockTimes());
            customerService.updateStatusCancelLock(businessSetBo);
        }

    }

    /**
     * 业务设置 定时任务-我的客户转公海 每天凌晨1点
     *
     * @param
     */
    public void taskBusinessSettingByMyCustomerToGonghai() {
        // 读取配置参数
        BusinessSet businessSet = businessSetService.get("index_set");
        if (null != businessSet) {
            BusinessSetBo businessSetBo = null;
            CustomerTest customerTest = new CustomerTest();
            customerTest.setTestType("1");
            customerTestService.deleteCustomerTestByType(customerTest);

            // 客户被领取后，前x(天)内，未连续跟进，客户自动转入公海。
            if (null != businessSet.getIsOneStatus() && 1 == businessSet.getIsOneStatus()) {
                businessSetBo = new BusinessSetBo();
                businessSetBo.setTime(businessSet.getContactTimesToGonghaiOne());
                customerService.updateStatusToHongHai3(businessSetBo);
            }
            // 客户被跟进后x(天)内，未再跟进，客户自动转入公海。锁住的客户除外
            if (null != businessSet.getIsTwoStatus() && 1 == businessSet.getIsTwoStatus()) {
                businessSetBo = new BusinessSetBo();
                businessSetBo.setTime(businessSet.getContactTimesToGonghaiTwo());
                customerService.updateStatusToHongHai15(businessSetBo);
            }
        }
    }

    /**
     * 业务设置 // 客户被领取后x(小时)内，未进行跟进，客户自动转入公海。
     *
     * @param
     */
    public void taskBusinessSettingByXianSuoChiCustomerToGonghai() {
        // 读取配置参数
        BusinessSet businessSet = businessSetService.get("index_set");
        if (null != businessSet) {
            BusinessSetBo businessSetBo = null;
            // 我的客户去公海
            if (null != businessSet.getIsCustomerToGonghai() && 1 == businessSet.getIsCustomerToGonghai()) {
                businessSetBo = new BusinessSetBo();
                businessSetBo.setTime(businessSet.getCustomerToGonghaiTimes());
                customerService.updateStatusToHongHai48(businessSetBo);
            }

            // 线索池去公海
            if (null != businessSet.getIsGetXianSuoToGonghai() && 1 == businessSet.getIsGetXianSuoToGonghai()) {
                businessSetBo = new BusinessSetBo();
                businessSetBo.setTime(businessSet.getXianSuoToGonghaiTimes());
                customerService.updateStatusToHongHaiXianSuoChi(businessSetBo);
            }
        }
    }

    /**
     * 业务设置 定时任务-取消重复标记
     *
     * @param
     */
    public void taskBusinessSettingByCancelRepCustomer() {
        // 读取配置参数
        BusinessSet businessSet = businessSetService.get("index_set");
        if (null != businessSet) {
            BusinessSetBo businessSetBo = null;
            // 取消重复标记
            if (null != businessSet.getIsRepMarkTimes() && 1 == businessSet.getIsRepMarkTimes()) {
                businessSetBo = new BusinessSetBo();
                businessSetBo.setTime(businessSet.getRepMarkTimes());
                customerService.updateStatusCancelRep(businessSetBo);
            }
        }
    }

    /**
     * 10分钟未跟进 重新分配
     *
     * @param
     */
    public void taskCustomerNotGenJinRep(Integer times, String setTimeStr, String endTimeStr, Integer countInTimes) throws ParseException {
        taskService.taskCustomerNotGenJinRep(times, setTimeStr, endTimeStr, countInTimes);
    }

    /**
     * 融享客-新接口
     */
    public void taskGetRxkOrderCustomersNews() {
        RxkOrder rxkOrderparam = new RxkOrder();
        rxkOrderparam.setStatus("0");
        RxkOrder rxkOrder = rxkOrderService.findListByStatus(rxkOrderparam);
        if (StringUtils.isNotNull(rxkOrder)) {
            int count = customerService.insertRongXinKe(rxkOrder.getOrderNo());
            if (count == 1) {
                rxkOrder.setStatus("1");
                rxkOrder.setVersion(rxkOrder.getVersion());
                rxkOrderService.save(rxkOrder);
            }
        }
    }

    public void taskJobLogLook(String name, String target) {
        SysJobLog sysJobLog = new SysJobLog();
        sysJobLog.setInvokeTarget(target);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (sysJobLogService.selectJobLogListByOne(sysJobLog) > 0) {
            String phone = ConfigUtils.getConfigValueByKey("sys.systemLog.phone");
            if (null != phone) {
                String[] phones = phone.split(";");
                for (String p : phones) {
                    // 【车优融】系统任务{s}当前状态异常请及时处理，时间：{s}
                    String content = ConfigUtils.getConfigValueByKey("sms.systemLog.template");
                    String params = p + "," + name + "," + sdf.format(new Date());
                    ChuangLanSmsClient.sendOthersSms(params, content);
                }
            }

        }
    }

    /**
     * 获取企业微信用户id
     */
    public void taskGetAllWxUserIds() {
        taskService.taskGetAllWxUserIds();
    }

    /**
     * 企微提醒
     */
    public void taskWxReminder() {
        taskService.taskWxReminder();
    }
}
